<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_weblinks
 *
 * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;
?>

<div class="video_home">

<?php foreach ($list as $item) :  

$img = video_imagem($item->url);


?>

<iframe width="405" height="362" src="<?php echo $img;?>" frameborder="0" allowfullscreen></iframe>

<?php 

endforeach;?>
</div>

<?php

function video_imagem($url){
	$url_imagem = parse_url($url);
	if($url_imagem['host'] == 'www.youtube.com' || $url_imagem['host'] == 'youtube.com'){
		$array = explode("&", $url_imagem['query']);
		return "//www.youtube.com/embed/".substr($array[0], 2);
	} else if($url_imagem['host'] == 'www.vimeo.com' || $url_imagem['host'] == 'vimeo.com'){
		$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/".substr($url_imagem['path'], 1).".php"));
		return $hash[0]["thumbnail_small"];
	}
}


?>
